<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<% 
	boolean admin = false;
	
	String name = String.valueOf(session.getAttribute("session_name"));
	
	if(session.getAttribute("session_name") == null){
		String destination ="login.jsp";
		response.sendRedirect(response.encodeRedirectURL(destination));
	}else{
		admin = (Boolean)session.getAttribute("is_admin");
	}

%>

<sql:transaction dataSource="jdbc/lut2">
    <sql:update var="count">
        INSERT INTO user_reviews VALUES (?, ?, ?);
        <sql:param>${param.school_id}</sql:param>
        <sql:param><%= name %></sql:param>
        <sql:param>${param.review}</sql:param>
    </sql:update>
</sql:transaction>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta http-equiv="refresh" content="0.1;url=index.jsp"> 
        <link rel="stylesheet" type="text/css" href="lutstyle.css">
        <title>Review added!</title>
    </head>
    <body>
        <!-- <h1>asasadsads ${param.name}!</h1> -->
        Your contribution is appreciated.<br>
        You will be redirected to the LUT2.0 main page in a few seconds.
    </tr>
    <span style="float:left;">
            <form action="logout.jsp">
<input type="submit" value="Logout">
</form>
</span>

<% if (admin == true) { %>
    <span style="float:left;">
        <form action="lutadmin.jsp">
			<input type="submit" value="Admin Panel">
		</form>
</span>
<% } %>

</body>
</html>
